<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="../layout.css" rel="stylesheet" type="text/css" media="screen" />
<%@page import="utility.connections"%>
<%! String user,type,matr,cogn,pwd,nome,cognome,email,matricola,tipologia; %>
<%
				if (session.getAttribute("user")==null)
				response.sendRedirect("loginerr.jsp");
				
				else
				{
		
				user = session.getAttribute("user").toString().toLowerCase();
				type = session.getAttribute("type").toString();
				matr = session.getAttribute("matricola").toString();
				nome = session.getAttribute("nome").toString();
				cogn = session.getAttribute("cognome").toString();
				}
%>
<script type="text/javascript">
	
	function modifica()
	{
		if(validate()) document.frmpwd.action='../mod_password';
	}
	
	function back()
	{
		document.frmpwd.action='account.jsp';
	}
	
	function validate()
	{
		frm = document.frmpwd;
		if(frm.newpwd.value.length<8)
		{
			alert("Lunghezza nuova password insufficente");
			return false;
		}
		if (frm.newpwd.value!=frm.cnfpwd.value)
		{
			alert("Corrispondenza password errata!");
			return false;
		}
		frm.submit();
		return true;
	}
</script>

<title>Insert title here</title>
</head>
<body>
<form name="frmpwd" action="" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="4"><div align="center">
      <h1><strong>MODIFICA PASSWORD </strong></h1>
    </div></td>
  </tr>
  <tr>
    <td height="61">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="6%">&nbsp;</td>
    <td width="21%">USER</td>
    <td width="67%"><input type="text" name="user" value="<%=user%>"></input></td>
    <td width="6%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>VECCHIA PASSWORD </td>
    <td><input type="password" name="oldpwd" value="" ></input></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>NUOVA PASSWORD </td>
    <td><input type="password" name="newpwd" value=""></input></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>CONFERMA PASSWORD </td>
    <td><input type="password" name="cnfpwd" value=""></input></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" value="CONFERMA" onclick="javascript:modifica();" /> 
        <input type="submit" value="INDIETRO" onclick="javascript:back();"></td>
    <td></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>